function filtered_w = wg_filter(w, property, operator, comparator)

switch operator
   case 'eq'
     filtered_w = w(arrayfun(@(x) x.(property) == comparator,w));
   case 'ge'
     filtered_w = w(arrayfun(@(x) x.(property) >= comparator,w));
   case 'gt'
     filtered_w = w(arrayfun(@(x) x.(property) > comparator,w));
   case 'le'
     filtered_w = w(arrayfun(@(x) x.(property) <= comparator,w));
   case 'lt'
     filtered_w = w(arrayfun(@(x) x.(property) < comparator,w));
   case 'ne'
     filtered_w = w(arrayfun(@(x) x.(property) ~= comparator,w));
   otherwise
      disp('Unknown operator.')
end


end